package com.example.controller;

import com.example.result.CommonResult;
import com.example.service.PostsService;
import com.example.vo.PostsVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject："smart-property"
 * @BelongsPackage："com.example.controller"
 * @CreateTime："2022-11-14 09:27"
 * @Description：帖子管理
 * @Author：LK
 */
@RestController
@RequestMapping("/posts")
public class Posts {

    @Autowired
    private PostsService postsService;

    /**
     * @description:帖子全查、分页
     * @author: lk
     * @date: 2022/11/14 10:07
     * @return: com.example.result.CommonResult
     **/
    @PostMapping("/postsCheck")
    public CommonResult postsCheck(@RequestBody PostsVO postsVO){
        return postsService.postsCheck(postsVO);
    }

    /**
     * @description:删除帖子
     * @author: lk
     * @date: 2022/11/14 13:49
     * @param: postsNumber
     * @return: com.example.result.CommonResult
     **/
    @PostMapping("/deletePosts/{postsNumber}")
    public CommonResult deletePosts(@PathVariable String postsNumber){
        if(postsService.deletePosts(postsNumber) > 0){
            return CommonResult.ok();
        }else{
            return CommonResult.fail();
        }
    }

}
